﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections;
using System.ComponentModel;

namespace G.Controls
{
    //[EditorBrowsable(EditorBrowsableState.Never)]
    //public class RadMessageBoxControl : Control
    //{
    //    private bool a;
    //    private CheckBox b;
    //    internal IEnumerable buttonsContent;
    //    internal DataTemplate buttonsTemplate;
    //    private ContentControl c;
    //    internal object checkBoxContent;
    //    internal Action<MessageBoxClosedEventArgs> closedHandler;
    //    private ContentControl d;
    //    private ContentControl e;
    //    internal bool enableVibration;
    //    [CompilerGenerated]
    //    private static Predicate<DependencyObject> f;
    //    [CompilerGenerated]
    //    private static Predicate<DependencyObject> g;
    //    [CompilerGenerated]
    //    private static Action<DependencyObject> h;
    //    [CompilerGenerated]
    //    private static Predicate<DependencyObject> i;
    //    internal bool initialCheckBoxValue;
    //    internal object message;
    //    internal object title;
    //    internal RadModalWindow window;

    //    internal RadMessageBoxControl(RadModalWindow window, Action<MessageBoxClosedEventArgs> messageBoxClosedHandler, object checkBoxContent, bool initialCheckBoxValue, bool vibrate, IEnumerable buttonsContent, object title, object message, ControlTemplate template, DataTemplate buttonsTemplate)
    //    {
    //        EventHandler<CancelEventArgs> handler = null;
    //        EventHandler<WindowClosedEventArgs> handler2 = null;
    //        base.DefaultStyleKey = typeof(RadMessageBoxControl);
    //        if (template != null) base.Template = template;
    //        this.buttonsTemplate = buttonsTemplate;
    //        this.closedHandler = messageBoxClosedHandler;
    //        this.window = window;
    //        this.checkBoxContent = checkBoxContent;
    //        this.buttonsContent = buttonsContent;
    //        this.initialCheckBoxValue = initialCheckBoxValue;
    //        this.enableVibration = vibrate;
    //        this.title = title;
    //        this.message = message;
    //        if (this.buttonsContent == null) this.buttonsContent = new object[0];
    //        if (handler == null) handler = new EventHandler<CancelEventArgs>(this.cl);
    //        this.window.WindowOpening += handler;
    //        if (handler2 == null) handler2 = new EventHandler<WindowClosedEventArgs>(this.eh);
    //        this.window.WindowClosed += handler2;
    //    }

    //    [CompilerGenerated]
    //    private void cl(object A_0, CancelEventArgs A_1)
    //    {
    //        if (this.enableVibration) this.g();
    //    }

    //    internal void Close()
    //    {
    //        this.window.IsOpen = false;
    //    }

    //    private void d1(object A_0, RoutedEventArgs A_1)
    //    {
    //        <>c__DisplayClass11 class2;
    //        Button button = (Button) A_0;
    //        this.window.WindowClosed += new EventHandler<WindowClosedEventArgs>(class2.<OnButtonClick>b__10);
    //        this.window.IsOpen = false;
    //    }

    //    [CompilerGenerated]
    //    private void eh(object A_0, WindowClosedEventArgs A_1)
    //    {
    //        if (A_1.CloseReason == WindowCloseReason.BackKeyPress) this.OnClosed(new MessageBoxClosedEventArgs(null, this.b.IsChecked.Value));
    //        RadMessageBox.CurrentMessageBox = null;
    //    }

    //    private void ei(DependencyObject A_0, TextWrapping A_1)
    //    {
    //        <>c__DisplayClasse classe;
    //        TextWrapping wrap = A_1;
    //        if (i == null) i = new Predicate<DependencyObject>(RadMessageBoxControl.ek);
    //        this.eo(A_0, i, new Action<DependencyObject>(classe.<FixTextWrap>b__c));
    //    }

    //    private void ej(ContentControl A_0, ContentControl A_1, CheckBox A_2, ContentControl A_3)
    //    {
    //        if (A_0 == null) throw new MissingTemplatePartException(typeof(ContentControl), "PART_Message");
    //        if (A_1 == null) throw new MissingTemplatePartException(typeof(ContentControl), "PART_Title");
    //        if (A_2 == null) throw new MissingTemplatePartException(typeof(CheckBox), "PART_CheckBox");
    //        if (A_3 == null) throw new MissingTemplatePartException(typeof(ContentControl), "PART_ButtonsContainer");
    //    }

    //    [CompilerGenerated]
    //    private static bool ek(DependencyObject A_0)
    //    {
    //        return (A_0 is TextBlock);
    //    }

    //    [CompilerGenerated]
    //    private static void el(DependencyObject A_0)
    //    {
    //        TextBlock block = A_0 as TextBlock;
    //        if (block != null) block.TextWrapping = TextWrapping.Wrap;
    //        if ((A_0 is Border) || (A_0 is Rectangle) || A_0 is Path)
    //        {
    //            FrameworkElement element = A_0 as FrameworkElement;
    //            element.VerticalAlignment = VerticalAlignment.Top;
    //            if (A_0 is Path)
    //                element.Margin = new Thickness(0.0, 14.0, 0.0, 0.0);
    //            else
    //                element.Margin = new Thickness(0.0, 8.0, 0.0, 0.0);
    //        }
    //    }

    //    [CompilerGenerated]
    //    private static bool em(DependencyObject A_0)
    //    {
    //        return true;
    //    }

    //    [CompilerGenerated]
    //    private static bool en(DependencyObject A_0)
    //    {
    //        return ((A_0 as FrameworkElement).Name == "PART_ButtonsPanel");
    //    }

    //    private void eo(DependencyObject A_0, Predicate<DependencyObject> A_1, Action<DependencyObject> A_2)
    //    {
    //        ElementTreeHelper.EnumVisualDescendants(A_0, A_1, TreeTraversalMode.BreadthFirst).Apply<DependencyObject>(A_2);
    //    }

    //    private void g()
    //    {
    //        VibrateController.Default.Start(TimeSpan.FromSeconds(0.1));
    //    }

    //    private void h()
    //    {
    //        if (f == null) f = new Predicate<DependencyObject>(RadMessageBoxControl.en);
    //        Panel panel = ElementTreeHelper.FindVisualDescendant<Panel>(this, f);
    //        if (panel == null) throw new MissingTemplatePartException(typeof(Panel), "PART_ButtonsPanel");
    //        if (this.a)
    //        {
    //            if (panel is StackPanel) (panel as StackPanel).Orientation = Orientation.Vertical;
    //            this.e.HorizontalAlignment = HorizontalAlignment.Stretch;
    //            this.e.VerticalAlignment = VerticalAlignment.Top;
    //        }
    //        else
    //        {
    //            this.e.HorizontalAlignment = HorizontalAlignment.Left;
    //            this.e.VerticalAlignment = VerticalAlignment.Bottom;
    //        }
    //        foreach (object obj2 in this.buttonsContent)
    //        {
    //            Button button2 = new Button
    //            {
    //                Content = obj2
    //            };
    //            Button button = button2;
    //            if (this.a)
    //            {
    //                button.HorizontalAlignment = HorizontalAlignment.Stretch;
    //                button.HorizontalContentAlignment = HorizontalAlignment.Left;
    //            }
    //            else
    //                button.Width = 228.0;
    //            panel.Children.Add(button);
    //            button.Click += new RoutedEventHandler(this.d1);
    //        }
    //        this.ei(this.c, TextWrapping.Wrap);
    //        this.ei(this.d, TextWrapping.Wrap);
    //        if (g == null) g = new Predicate<DependencyObject>(RadMessageBoxControl.em);
    //        if (h == null) h = new Action<DependencyObject>(RadMessageBoxControl.el);
    //        this.eo(this.b, g, h);
    //    }

    //    public override void OnApplyTemplate()
    //    {
    //        base.OnApplyTemplate();
    //        ContentControl templateChild = (ContentControl)base.GetTemplateChild("PART_Title");
    //        this.c = templateChild;
    //        ContentControl control2 = (ContentControl)base.GetTemplateChild("PART_Message");
    //        this.d = control2;
    //        CheckBox box = (CheckBox)base.GetTemplateChild("PART_CheckBox");
    //        ContentControl control3 = (ContentControl)base.GetTemplateChild("PART_ButtonsContainer");
    //        this.e = control3;
    //        this.ej(templateChild, control2, box, control3);
    //        if (this.buttonsTemplate != null)
    //            control3.ContentTemplate = this.buttonsTemplate;
    //        else if (this.buttonsContent.Count() > 2) this.a = true;
    //        this.b = box;
    //        this.b.IsChecked = new bool?(this.initialCheckBoxValue);
    //        if (this.checkBoxContent == null)
    //            box.Visibility = Visibility.Collapsed;
    //        else
    //            box.Content = this.checkBoxContent;
    //        if (templateChild.Content == null)
    //        {
    //            templateChild.Content = this.title;
    //            if (templateChild.Content == null) templateChild.Visibility = Visibility.Collapsed;
    //        }
    //        if (control2.Content == null)
    //        {
    //            control2.Content = this.message;
    //            if (control2.Content == null) control2.Visibility = Visibility.Collapsed;
    //        }
    //        if (base.IsLoaded) this.h();
    //    }

    //    protected virtual void OnClosed(MessageBoxClosedEventArgs args)
    //    {
    //        if (this.closedHandler != null) this.closedHandler(args);
    //    }

    //    protected override void OnLoaded(object sender, RoutedEventArgs e)
    //    {
    //        base.OnLoaded(sender, e);
    //        if (base.IsTemplateApplied) this.h();
    //        base.Focus();
    //    }
    //}
}
